﻿using WenAntdUI.Controls;


namespace WenAntdUI
{
    public partial class MenuForm : WenForm
    {
        public MenuForm()
        {
            this.IsShowThemeButton = true;
            hmt = new HamburgerMenuTabs() { Dock = DockStyle.Fill };
            this.Controls.Add(hmt);
            this.Controls.SetChildIndex(hmt, 0);

            userInfo = new UserInfo()
            {
                Dock = DockStyle.Right,
                Width = 100
            };
            this.TopControls.Add(userInfo);
        }

        #region 公有属性

        [Category("外观")]
        [Description("是否显示用户信息")]
        public bool IsShowUserInfo { get => userInfo.Visible; set => userInfo.Visible = value; }
        [Category("用户信息")]
        [Description("默认图标")]
        public string UserInfoIconSvg { get => userInfo.IconSvg; set => userInfo.IconSvg = value; }
        [Category("用户信息")]
        [Description("图档")]
        public Image UserInfoImage { get => userInfo.Image; set => userInfo.Image = value; }
        [Category("用户信息")]
        [Description("用户名称")]
        public string UserInfoDisplayName { get => userInfo.DisplayName; set => userInfo.DisplayName = value; }
        [Category("用户信息")]
        [Description("图标尺寸")]
        public Size UserInfoIconSize { get => userInfo.IconSize; set => userInfo.IconSize = value; }
        #endregion

        #region 私有属性

        private readonly HamburgerMenuTabs hmt;
        private readonly UserInfo userInfo;
        #endregion

        #region 公用方法

        /// <summary>
        /// 设置菜单
        /// </summary>
        public void SetMenuTabs(List<MenuTagItem> myMenuItems, bool showFirstPage = false)
        {
            hmt.SetMenu(myMenuItems);
            if (showFirstPage)
            {
                hmt.MenuSelectDefault();
            }
        }
        #endregion
    }
}
